﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DockSample
{
    public class Attribute
    {
        private String accessModifier;
        private String attributeType;
        private String attributeName;
        private String initialValue;
        private String description;
        public String id;
        private List<NonFunctionRequirment> attributeNFRList = new List<NonFunctionRequirment>();
        //
        public Attribute parentAttr;
        public string parentAttrId;
        public OriginalDiagram assoState;
        public string assoStateId;

        public bool isComplex;

        public List<NonFunctionRequirment> AttributeNFRList
        {
            get { return attributeNFRList; }
            set { attributeNFRList = value; }
        }
        //###################################################################################
        public Attribute(String accessModifier, String attributeType, String attributeName, String initialValue, String description = "")
        {
            this.accessModifier = accessModifier;
            this.attributeType = attributeType;
            this.attributeName = attributeName;
            this.initialValue = initialValue;
            this.description = description;
            this.id = System.Guid.NewGuid().ToString();
        }

        public Attribute(String accessModifier, String attributeType, String attributeName, String initialValue, String id, String description = "")
        {
            this.accessModifier = accessModifier;
            this.attributeType = attributeType;
            this.attributeName = attributeName;
            this.initialValue = initialValue;
            this.description = description;
            this.id = id;
        }


        //***********************************************************************************
        public String AccessModifier
        {
            get { return accessModifier; }
            set { accessModifier = value; }
        }
        public String AttributeType
        {
            get { return attributeType; }
            set { attributeType = value; }
        }
        public String AttributeName
        {
            get { return attributeName; }
            set { attributeName = value; }
        }
        public String InitialValue
        {
            get { return initialValue; }
            set { initialValue = value; }
        }
        public String Description
        {
            get { return description; }
            set { description = value; }
        }
        //***********************************************************************************
        public override string ToString()
        {
            if (parentAttr != null && initialValue != "")
            {
                return parentAttr.attributeName + "  " + accessModifier + "  " + attributeType + "  " + attributeName + " = " + initialValue + ";" + "  " + description;
            }
            else if (initialValue != "")
            {
                return accessModifier + "  " + attributeType + "  " + attributeName + " = " + initialValue + ";" + "  " + description;
            }
            else
            {
                return accessModifier + "  " + attributeType + "  " + attributeName + " " + ";" + "  " + description;
            }
        }
        public String getShowString()
        {
            String showStr = "";
            switch (accessModifier)
            {
                case "public":
                    showStr = "+";
                    break;
                case "private":
                    showStr = "-";
                    break;
                case "protected":
                    showStr = "#";
                    break;
                default:
                    showStr = "";
                    break;
            }
            return showStr + "  " + attributeType + "  " + attributeName;
        }
    }
}
